import java.awt.event.WindowAdapter;
import java.io.File;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;




public class DemoJFileChooser extends JFrame{
	   JButton go;
	   
	   static JFileChooser chooser;
	   String choosertitle;
	   JTextArea textbox;
	  public DemoJFileChooser() {
		  	this.setSize(400,300);
		  	this.setTitle("DEMO FILE CHOOSER - TITLE FRAME");
		    go = new JButton("Do it");
		    textbox = new JTextArea("sdfasdfasf");
		    chooser = new JFileChooser(new File("C:\\filewalker"));
		    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
		    
		    add(go);
		    add(textbox);
		  }

		    
		  public static void main(String s[]) {
		    DemoJFileChooser frame = new DemoJFileChooser();
		    frame.setVisible(true);

		    int ret = chooser.showDialog(null, "Open File");
		    if(ret == JFileChooser.APPROVE_OPTION){
		    	File file = chooser.getSelectedFile();
		    	System.out.println(file);
		    }
		   }

}
